class PositionCertificateStandardsController < InheritedResources::Base
  respond_to :json
  load_resource

  def index
    @position_certificate_standards = PositionCertificateStandard.all
    respond_with PositionCertificateStandardJsonSerializer.index_as_json @position_certificate_standards
  end

  def create
    position_standard = AddPositionStandard.run permitted_params
    render CommandJsonSerializer.as_json position_standard
  end

  def show
    respond_with PositionCertificateStandardJsonSerializer.show_as_json @position_certificate_standard
  end

  def get_position_standards
    @position_certificate_standards = PositionCertificateStandard.where(position_id: params[:position_id])
    respond_with PositionCertificateStandardJsonSerializer.index_as_json @position_certificate_standards
  end

  def list_lost_certificate
    respond_with Employee.list_all_lost_certificates
  end

  private
  def permitted_params
    JSON.parse(request.body.read)
    # params.permit(:position_id, :requre_certificate_organ, :certificate_ids)
  end

  def position_certificate_standard_params
    params.require(:position_certificate_standard).permit(:requre_certificate_organ => [:name], :position => [:id], :certificate => [:id])
  end
  
end